import request from '@/utils/request'
import type { PageDto, PageReqDto, PagesDto } from '../types'
import type { InsureEnsurePlanDto, InsureCompanyListReqDto, InsureEnsurePlanListDto, AddFeeReqDto, EditFeeReqDto } from './types'


/**
 * 获取长期保行业列表
 * @param params 
 * @returns 
 */
export function getInsureEnsurePlanList(params: PageReqDto & {
    planName?: string
    name?: string
    insureCompanyId?: number
}): Promise<PageDto<InsureEnsurePlanListDto>> {
    return request.get('/crm-prod-v2/web/pc/crm/insureEnsurePlan/list', {
        params
    })
}

/**
 * 新增投保方案
 * @param params 
 * @returns 
 */
export function addInsureEnsurePlan(data: InsureEnsurePlanDto): Promise<number> {
    return request.post('/crm-prod-v2/web/pc/crm/insureEnsurePlan/add', data)
}

/**
 * 编辑投保方案
 * @param params 
 * @returns 
 */
export function editInsureEnsurePlan(data: InsureEnsurePlanDto): Promise<void> {
    return request.post('/crm-prod-v2/web/pc/crm/insureEnsurePlan/edit', data)
}

/**
 * 获取保司方案列表
 * @param data 
 * @returns 
 */
export function getInsureCompanyPlans(params: InsureCompanyListReqDto): Promise<{
    key: string
    value: number
}[]> {
    return request.get('/crm-prod-v2/web/pc/crm/insureCompanyPlan/getKeyValueList', {
        params
    })
}

/**
 * 获取保司方案详情
 * @param params 
 * @returns 
 */
export function insureEnsurePlanDetail(params: {
    id: number
}): Promise<InsureEnsurePlanListDto> {
    return request.get('/crm-prod-v2/web/pc/crm/insureEnsurePlan/detail', {
        params
    })
}

/**
 * 获取保费记录
 * @param params 
 * @returns 
 */
export function getFeeList(params: PageReqDto & {
    month?: string
    planId: number
}): Promise<PageDto<InsureEnsurePlanDto>> {
    return request.get('/crm-prod-v2/web/pc/crm/insureEnsurePlan/feeList', {
        params
    })
}

/**
 * 保费记录新增
 * @param data 
 * @returns 
 */
export function addFee(data: AddFeeReqDto): Promise<void> {
    return request.post('/crm-prod-v2/web/pc/crm/insureEnsurePlan/addFee', data)
}

/**
 * 保费记录编辑
 * @param data 
 * @returns 
 */
export function editFee(data: EditFeeReqDto): Promise<void> {
    return request.post('/crm-prod-v2/web/pc/crm/insureEnsurePlan/editFee', data)
}

/**
 * 删除保费记录
 * @param data 
 * @returns 
 */
export function removeFee(data: {
    id: number
    feeId: number
}): Promise<void> {
    return request.post('/crm-prod-v2/web/pc/crm/insureEnsurePlan/removeFee', data)
}


// export function removeFee(data: {
//     id: number
//     feeId: number
// }): Promise<void> {
//     return request.get('/crm-prod-v2/web/pc/crm/insureCompanyPlanNumber/queryPageList', data)
// }



